/**
 *
 */
package com.ssyt.examinationsystem.service.impl;

import com.ssyt.examinationsystem.dao.IBlankInfoDAO;
import com.ssyt.examinationsystem.dao.impl.BlankInfoDAOImpl;
import com.ssyt.examinationsystem.entity.BlankInfo;
import com.ssyt.examinationsystem.entity.PageBean;
import com.ssyt.examinationsystem.service.IBlankInfoService;

import java.util.List;
import java.util.Map;

/**
 * @author Long.
 * @version 1.0
 * @className BlankInfoServiceImpl
 * @since 2016年10月30日
 */
public class BlankInfoServiceImpl implements IBlankInfoService {
    IBlankInfoDAO blankDao = new BlankInfoDAOImpl();

    @Override
    public int addBlankInfo(BlankInfo blank) {
        return blankDao.addBlankInfo(blank);
    }

    @Override
    public List<Map<String, Object>> getBlank() {
        return blankDao.getBlank();
    }

    @Override
    public int updateBlank(BlankInfo blank) {
        return blankDao.updateBlank(blank);
    }

    @Override
    public int deleteBlank(String blankId) {
        return blankDao.deleteBlank(blankId);
    }

    @Override
    public PageBean getBlankByPage(PageBean page) {
        // 获取分页总记录数
        Integer totalRecords = blankDao.getTotalCount();
        // 获取每页显示数
        Integer pageSize = page.getPageSize();
        // 获取当前页
        Integer currentPage = page.getCurrentPage();
        List<Map<String, Object>> blankList = blankDao.getBlankByPage(page);
        // 创建一个分页对象
        PageBean pageBean = new PageBean(totalRecords, pageSize, currentPage);
        pageBean.setList(blankList);

        return pageBean;
    }

}
